Title: SQL W3S (By-BKK) / 022 IN
Tags: Obsidian_to_Anki

Q: What does the SQL IN operator do?
A: It allows you to specify multiple values in a WHERE clause.

Q: Is the IN operator a shorthand for multiple OR conditions?
A: True

Q: How do you write SQL syntax using the IN operator?
A: SELECT column_name(s) FROM table_name WHERE column_name IN (value1, value2, …);

Q: Give an example of using IN to get customers from Germany, France, or UK.
A: SELECT * FROM Customers WHERE Country IN ('Germany', 'France', 'UK');

Q: What does the NOT IN operator do?
A: It returns all records that are NOT any of the values in the list.

Q: How do you use NOT IN in SQL?
A: SELECT * FROM Customers WHERE Country NOT IN ('Germany', 'France', 'UK');

Q: Can you use IN with a subquery in SQL?
A: True

Q: How do you use IN with a subquery?
A: SELECT * FROM Customers WHERE CustomerID IN (SELECT CustomerID FROM Orders);

Q: Give an example: Select customers who have placed orders using IN and subquery.
A: SELECT * FROM Customers WHERE CustomerID IN (SELECT CustomerID FROM Orders);

Q: How do you use NOT IN with a subquery?
A: SELECT * FROM Customers WHERE CustomerID NOT IN (SELECT CustomerID FROM Orders);

Q: What is returned by NOT IN (SELECT) in the example?
A: All customers who have not placed any orders.

Q: True or False: IN can be used only with numbers.
A: False

Q: Select all records where column value matches a list using which operator?
A: IN

Q: IN is used in which SQL clause?
A: WHERE

Q: Reverse: Allows you to specify multiple values in a WHERE clause.
A: What does the SQL IN operator do?

Q: Reverse: True
A: Is the IN operator a shorthand for multiple OR conditions?

Q: Reverse: SELECT * FROM Customers WHERE Country IN ('Germany', 'France', 'UK');
A: Give an example of using IN to get customers from Germany, France, or UK.

Q: Reverse: It returns all records that are NOT any of the values in the list.
A: What does the NOT IN operator do?

Q: Reverse: SELECT * FROM Customers WHERE CustomerID IN (SELECT CustomerID FROM Orders);
A: How do you use IN with a subquery?